package com.wkq.common.glide.disk

import com.bumptech.glide.load.engine.cache.DiskCache
import java.io.File

/**
 *
 *@Author: wkq
 *
 *@Time: 2025/4/10 13:43
 *
 *@Desc:
 */
class VoiceDiskCacheFactory(var cacheDirectoryGetter: CacheDirectoryGetter) :
    DiskCache.Factory {

    interface CacheDirectoryGetter {
        val cacheDirectory: File

    }

    override fun build(): DiskCache? {
        val cacheDir: File =
            cacheDirectoryGetter.cacheDirectory

        cacheDir.mkdirs()


        return if ((!cacheDir.exists() || !cacheDir.isDirectory)) {
            null
        } else VoiceDiskLruCacheWrapper.create(
            cacheDir,
            500 * 1024 * 1024
        )

    }
}
